{{csrf_field()}}
<div class="layui-form-item">
    <label for="" class="layui-form-label">分类</label>
    <div class="layui-input-inline">
        <select name="category_id">
            <option value="0"></option>
            @foreach($categories as $category)
                <option value="{{ $category->id }}"
                        @if(isset($article->category_id)&&$article->category_id==$category->id)selected @endif >{{ $category->name }}</option>
                @if(isset($category->allChilds)&&$category->allChilds->isNotEmpty())
                    @foreach($category->allChilds as $child)
                        <option value="{{ $child->id }}"
                                @if(isset($article->category_id)&&$article->category_id==$child->id)selected @endif >
                            &nbsp;&nbsp;&nbsp;┗━━{{ $child->name }}</option>
                        @if(isset($child->allChilds)&&$child->allChilds->isNotEmpty())
                            @foreach($child->allChilds as $third)
                                <option value="{{ $third->id }}"
                                        @if(isset($article->category_id)&&$article->category_id==$third->id)selected @endif >
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;┗━━{{ $third->name }}</option>
                            @endforeach
                        @endif
                    @endforeach
                @endif
            @endforeach
        </select>
    </div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">标签</label>
    <div class="layui-input-block">
        @foreach($tags as $tag)
            <input type="checkbox" name="tags[]" {{ $tag->checked??'' }} value="{{ $tag->id }}"
                   title="{{ $tag->name }}">
        @endforeach
    </div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">标题</label>
    <div class="layui-input-block">
        <input type="text" name="title" value="{{$article->title??old('title')}}" lay-verify="required"
               placeholder="请输入标题" class="layui-input">
    </div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">关键词</label>
    <div class="layui-input-block">
        <input type="text" name="keywords" value="{{$article->keywords??old('keywords')}}" placeholder="请输入关键词"
               class="layui-input">
    </div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">描述</label>
    <div class="layui-input-block">
        <textarea name="description" placeholder="请输入描述"
                  class="layui-textarea">{{$article->description??old('description')}}</textarea>
    </div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">点击量</label>
    <div class="layui-input-block">
        <input type="number" name="click" value="{{$article->click??mt_rand(100,500)}}" class="layui-input">
    </div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">是否推荐</label>
    <div class="layui-input-block">
        <input type="checkbox" name="recommend" value="1" lay-skin="switch" lay-text="是|否">
    </div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">缩略图</label>
    <div class="layui-input-block">
        <div class="layui-upload">
            <button type="button" class="layui-btn layui-btn-sm uploadPic"><i class="layui-icon">&#xe67c;</i>图片上传
            </button>
            <div class="layui-upload-list">
                <ul class="layui-upload-box layui-clear">
                    @if(isset($article->thumb))
                        <li><img src="{{ $article->thumb }}"/>
                            <p>上传成功</p></li>
                    @endif
                </ul>
                <input type="hidden" name="thumb" class="layui-upload-input" value="{{ $article->thumb??'' }}">
            </div>
        </div>
    </div>
</div>

{{--<div class="layui-form-item">--}}
    {{--<label for="" class="layui-form-label">内容</label>--}}
    {{--<div class="layui-input-block">--}}
        {{--<div id="container" name="html" type="text/plain" style="width: 98%">--}}
            {{--{!! $article->html??old('html') !!}--}}
        {{--</div>--}}
    {{--</div>--}}
{{--</div>--}}

<div class="layui-form-item layui-form-text">
    <label class="layui-form-label"> 内容 </label>
    <div class="layui-input-block">
        <div id="md-content">
            <textarea name="markdown" placeholder="请输入文章内容"
                      class="layui-textarea">{!! $article->markdown??old('markdown') !!}</textarea>
        </div>
    </div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label"> 外链 </label>
    <div class="layui-input-block">
        <input type="text" name="link" value="{{$article->link??''}}" placeholder="资讯外部链接，可为空" class="layui-input">
    </div>
</div>

<div class="layui-form-item">
    <div class="layui-input-block">
        <button type="submit" class="layui-btn" lay-submit="" lay-filter="formDemo">确认</button>
        <a class="layui-btn" href="{{route('admin.article')}}"> 返回 </a>
    </div>
</div>